import java.util.ArrayList;
import java.util.List;

/**
 * Author is identified by the given email, first name and last name.
 * 
 * @author Xi Luo
 * 
 */
public class Author {

   private String email;
   private String firstName;
   private String lastName;

   // the books/magazines of the author
   private List<File> files = new ArrayList<File>();

   public Author(String email, String firstName, String lastName) {
      this.email = email;
      this.firstName = firstName;
      this.lastName = lastName;
   }

   public String getEmail() {
      return email;
   }

   public void setEmail(String email) {
      this.email = email;
   }

   public String getFirstName() {
      return firstName;
   }

   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }

   public String getLastName() {
      return lastName;
   }

   public void setLastName(String lastName) {
      this.lastName = lastName;
   }

   public List<File> getFiles() {
      return files;
   }

   public void setBooks(List<File> files) {
      this.files = files;
   }
   /**
    * Check if the given book/magazine is contained in the file list of the author.
    * 
    * @param id id can be isbn number or title of book/magazine
    * @return
    */
   public boolean containsFile(String id){
      for(File file:files){
         if(id.equals(file.getIsbn())||id.equals(file.getTitle())){
            return true;
         }
      }
      return false;
   }
}
